package MultiThread;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class ThreadStateTest {
    public static void main(String[] args) throws InterruptedException {
        TestLock testLock = new TestLock();

        Thread thread2 = new Thread(testLock::myTestLock, "thread2");

        Thread thread1 = new Thread(testLock::myTestLock, "thread1");

        thread1.start();
        Thread.sleep(200000);

        thread2.start();;
        Thread.sleep(1000);

        System.out.println("****" + (thread2.getState()));

        Thread.sleep(20000);
    }
}

class TestLock{
    private final Lock lock = new ReentrantLock();

    public void myTestLock() {
        lock.lock();
        try {
            Thread.sleep(1000);
            System.out.println("testLock status");
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            lock.unlock();
        }
    }
}
